package admin.board.category.action;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import admin.board.category.dao.CategoryDao;
import admin.board.category.dto.CategoryDto;
import admin.common.AdminUtil;

import com.opensymphony.xwork2.ActionSupport;

public class WriteAction extends ActionSupport {
	private CategoryDto dto;
	private CategoryDao dao;
	private List<Integer> possibleNumList;
	
	private int category_no;
	private String name;
	private int view_level;
	private String link_page;

	public WriteAction() {
		dao = CategoryDao.getInstance();
	}
	
	public String form() throws SQLException {
		possibleNumList = AdminUtil.checkPossibleNum(1, 10, 0, dao);
		
		return SUCCESS;
	}
	
	public String execute() throws Exception {
		dto = new CategoryDto();
		dto.setAll(category_no, name, view_level, link_page);
		
		dao.insert(dto);
		
		return SUCCESS;
	}

	public CategoryDto getDto() {
		return dto;
	}
	
	public List<Integer> getPossibleNumList() {
		return possibleNumList;
	}
	
	public int getCategory_no() {
		return category_no;
	}

	public void setCategory_no(int category_no) {
		this.category_no = category_no;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getView_level() {
		return view_level;
	}

	public void setView_level(int view_level) {
		this.view_level = view_level;
	}

	public String getLink_page() {
		return link_page;
	}

	public void setLink_page(String link_page) {
		this.link_page = link_page;
	}
}
